package com.lvxh.exp.utils;

import java.util.ArrayList;
import java.util.List;

import com.lvxh.exp.bean.TableProperties;

public class Run
{

    /**
     * @param args
     * 
     *            jdbc.driverClass=com.mysql.jdbc.Driver
     *            jdbc.url=jdbc:mysql://192.168.1.29:3306/kjftdatabase
     *            jdbc.username=root jdbc.password=root
     * 
     * 
     */
    public static void main(String[] args)
    {
        // String fileAboPath = "E:/workspacenew/ExpUtil/src/com/lvxh/exp/dao/";
        // String filePackage = "com.lvxh.exp.dao";

        String fileAboPath = "E:/temp/src/com/lvxh/exp/";
        String jspPath = "E:/temp/web/";
        String filePackage = "com.lvxh.exp";

        String driver = "com.mysql.jdbc.Driver";
        String url = "jdbc:mysql://192.168.1.180:3306/expweb";
        String user = "root";
        String pwd = "root";
        List<String> list = DBUtil.getTablesName(driver, url, user, pwd);
        // List<String> list = new ArrayList<String>();
        // list.add("remoteroom2local");
        for (String tableName : list)
        {
            List<TableProperties> plist = DBUtil.getTablesProperty(tableName,
                    driver, url, user, pwd);

            BeanUtil.initJavaBean(fileAboPath, tableName, filePackage,plist);
            BeanUtil.initMapperBean(fileAboPath, tableName, filePackage);
            XmlUtil.initMybatisXml(fileAboPath, tableName, filePackage,plist);
            BeanUtil.initServiceBean(fileAboPath, tableName, filePackage);
            BeanUtil.initImplBean(fileAboPath, tableName, filePackage);
            BeanUtil.initController(fileAboPath, tableName, filePackage);
            XmlUtil.initQueryJsp(jspPath, tableName, plist);
            XmlUtil.initModifyJsp(jspPath, tableName, plist);
            XmlUtil.initAddJsp(jspPath, tableName, plist);
            BeanUtil.getControllerFram(filePackage, tableName);
        }
        XmlUtil.initMybatisConfig(fileAboPath, list, filePackage);

    }

}
